package com.project.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.bean.ClassBean;
import com.project.bean.StudentBean;
import com.project.mapper.IClassMapper;
import com.project.mapper.IStudentMapper;
import com.project.service.IStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @Author(王思翰)
 * @Description(类的描述)
 * @Date(创建时间) 2021/7/14 8:52
 */
@Service
@Transactional
public class StudentServiceImpl implements IStudentService {
    @Autowired
    private IStudentMapper mapper;

    @Autowired
    private IClassMapper classMapper;


    @Override
    public PageInfo<StudentBean> findByItem(int pageNO, String studentName, String studentSchool) {
        PageHelper.startPage(pageNO,3);
        PageInfo<StudentBean> pageInfo=PageInfo.of(mapper.findByItem(studentName,studentSchool));
        return pageInfo;
    }

    @Override
    public void addStudent(StudentBean studentBean) {
        mapper.addStudent(studentBean);
    }

    @Override
    public void updateStudent(int studentId, ClassBean newClassBean, String newPhone) {
        mapper.updateStudent(studentId,newClassBean,newPhone);
    }

    @Override
    public void delStudent(int studentId) {
        mapper.delStudent(studentId);
    }

    @Override
    public StudentBean findById(int id) {
        return mapper.findById(id);
    }
}
